package com.qst.itoffer.mapper;

import com.qst.itoffer.entity.Company;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CompanyMapper {
    @Insert("INSERT INTO tb_company(company_name, company_area, company_size, " +
            "company_type, company_brief, company_state, company_sort, " +
            "company_viewnum, company_pic) " +
            "VALUES(#{companyName}, #{companyArea}, #{companySize}, " +
            "#{companyType}, #{companyBrief}, #{companyState}, #{companySort}, " +
            "#{companyViewnum}, #{companyPic})")
    @Options(useGeneratedKeys = true, keyProperty = "companyId")
    void insert(Company company);
    //查询所有公司
    @Select("SELECT * FROM tb_company")
    List<Company> selectAll();
    //通过id查询公司
    @Select("SELECT * FROM tb_company WHERE company_id = #{companyId}")
    Company selectById(Integer companyId);
    //修改公司
    @Update("UPDATE tb_company SET company_name=#{companyName}, company_area=#{companyArea}, " +
            "company_size=#{companySize}, company_type=#{companyType}, company_brief=#{companyBrief}, " +
            "company_state=#{companyState}, company_sort=#{companySort}, company_pic=#{companyPic} " +
            "WHERE company_id=#{companyId}")
    void update(Company company);

    @Delete("DELETE FROM tb_company WHERE company_id = #{companyId}")
    void delete(Integer companyId);
}
